# -*- coding: utf-8 -*-
"""
Created on Thu Mar 19 15:44:16 2020

@author: Administrator
"""

from selenium import webdriver
driver = webdriver.Chrome()
# driver.get("http://member.rltxtest.xyz/login/login.html")
driver.get("http://srm.nepstar.cn")

# 获取cookie信息
cookies = driver.get_cookies()
# 打印获取的cookies信息
print(cookies)

driver.quit()



from selenium import webdriver

driver = webdriver.Chrome()
# driver.get("http://member.rltxtest.xyz/login/login.html")

# 向cookie中name和value中添加回话信息
driver.add_cookie ({'name': 'JSESSIONID','value': '4217B3B44F09B54D710A3A4829BE02B5'})
#driver.add_cookie ({'domain': '.nepstar.cn', 'httpOnly': True, 'name': 'uid', 'path': '/', 'secure': False, 'value': 'wATJkA4UNm-YZWcfYs1q5s1aNipnavdiC5DDAOx9UH2W0jH7ESqbctcRQxzCYm6yxhPW6NEEGQyQiBVd_iejD3sKSpCBDzRKzBS80b2ht-T2JXSKCL8jwmOZIkPvmHR0'}, {'domain': 'srm.nepstar.cn', 'expiry': 1585210263.349749, 'httpOnly': False, 'name': '__u', 'path': '/ELSServer_HWXC/login', 'secure': False, 'value': 'MTAwMQ=='}, {'domain': '.nepstar.cn', 'httpOnly': True, 'name': 'JSESSIONID', 'path': '/', 'secure': False, 'value': '4217B3B44F09B54D710A3A4829BE02B5'}, {'domain': 'srm.nepstar.cn', 'expiry': 1585210261.665711, 'httpOnly': False, 'name': 'rememberPwd', 'path': '/', 'secure': False, 'value': 'true'}, {'domain': 'srm.nepstar.cn', 'expiry': 1585210263.349569, 'httpOnly': False, 'name': '__p', 'path': '/ELSServer_HWXC/login', 'secure': False, 'value': 'enozNzM3'}, {'domain': 'srm.nepstar.cn', 'expiry': 1585210261.666211, 'httpOnly': False, 'name': 'autoLogin', 'path': '/', 'secure': False, 'value': 'true'}, {'domain': 'srm.nepstar.cn', 'expiry': 1585210263.348742, 'httpOnly': False, 'name': '__e', 'path': '/ELSServer_HWXC/login', 'secure': False, 'value': 'MTEwODI5'})
driver.get("http://srm.nepstar.cn/ELSServer_HWXC/default2.jsp?account=110829_1001&loginChage=N&telphone1=18279409642")

# 遍历cookie中name和value信息并打印对应的信息，并包括添加对应的信息
for cookie in driver.get_cookies ():
    print("%s->%s" % (cookie['name'], cookie['value']))

driver.quit ()


from selenium import webdriver
driver = webdriver.Firefox()
# driver.get("http://member.rltxtest.xyz/login/login.html")
driver.get("http://www.youdao.com")

# 获取cookie信息
cookies = driver.get_cookies()
# 打印获取的cookies信息
print(cookies)

driver.quit()


from selenium import webdriver

driver = webdriver.Firefox ()
# driver.get("http://member.rltxtest.xyz/login/login.html")
driver.get ("http://www.youdao.com")
# 向cookie中name和value中添加回话信息
driver.add_cookie ({'name': 'key-aaaaaaa'}, {'value': 'value-bbbbb'})

# 遍历cookie中name和value信息并打印对应的信息，并包括添加对应的信息
for cookie in driver.get_cookies ():
    print("%s->%s" % (cookie['name'], cookie['value']))

driver.quit ()


from selenium import webdriver
import time

driver = webdriver.Chrome()
# driver.get("http://member.rltxtest.xyz/login/login.html")
driver.get("http://srm.nepstar.cn")
#将用户名密码写入浏览器cookie中
driver.add_cookie({'name':'elsAccount','value':'110829'})
driver.add_cookie({'name':'elsSubAccountPassword','value':'zz3737'})
#再次访问网站，将会自动登录
driver.get("http://srm.nepstar.cn/ELSServer_HWXC")
